package com.hks.web.controller;

import com.hks.common.utils.ResponseResult;
import com.hks.pojo.Menu;
import com.hks.pojo.User;
import com.hks.service.MenuService;
import com.hks.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/test")
public class TestController {

    @Autowired
    private TestService service;

    @Autowired
    private MenuService menuService;

    @GetMapping("/t")
    public String test(){
        return service.print();
    }

    @GetMapping("/list")
    @PreAuthorize("hasAnyAuthority('admin','user')")
    public String getList(){
        return "普通权限访问";
    }

    @GetMapping("/admin")
    @PreAuthorize("hasAuthority('admin')")
    public String getAdmin(){
        return "管理员权限访问";
    }

    @GetMapping("/code")
    public ResponseResult getCode(@RequestParam String timestamp){
        return service.getCode(timestamp);
    }
}
